//
//  UINavigationItem+offset.m
//  YiJuZhangShou2.0
//
//  Created by URANUS on 16/4/26.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

#import "UINavigationItem+offset.h"

@implementation UINavigationItem (offset)

- ( void )addLeftBarButtonItem:(UIBarButtonItem *)leftBarButtonItem
                    withOffset:(CGFloat)offset{
    if (([[[UIDevice currentDevice] systemVersion] floatValue]>= 7.0 ?YES:NO)) {
        UIBarButtonItem *negativeSpacer = [[ UIBarButtonItem alloc ] initWithBarButtonSystemItem : UIBarButtonSystemItemFixedSpace
                                           
                                                                                          target : nil action : nil];
        
        negativeSpacer.width = offset ;
        [self setLeftBarButtonItems :[NSArray arrayWithObjects:negativeSpacer, leftBarButtonItem, nil]];
        
    } else {
        [self setLeftBarButtonItem :leftBarButtonItem];
        
    }
    
}

- (void)addRightBarButtonItem:(UIBarButtonItem *)rightBarButtonItem
                    withOffset:(CGFloat)offset{
    if (([[[UIDevice currentDevice] systemVersion] floatValue]>= 7.0 ?YES:NO)) {
        UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem : UIBarButtonSystemItemFixedSpace
                                                                                          target : nil action : nil];
        
        negativeSpacer. width = offset;
        [self setRightBarButtonItems :[NSArray arrayWithObjects :negativeSpacer, rightBarButtonItem, nil]];
        
    } else {
        [self setRightBarButtonItem :rightBarButtonItem];
        
    }
    
}



@end
